<% content_for :menu do %>
<%= render :partial => "layouts/menu", :locals => {:accueil => true} %>
<% end %>

<% content_for :filAriane do %>
<div id="fil_ariane">
	Accueil
</div>
<% end %>



<noscript>
	<span class="js_desactive"> <%= image_tag('warning.png', :title => "Alerte !",:alt =>"incident", :height =>"16px", :width =>"16px" )%> Javascript est desactivé, merci de l'activer pour profiter pleinement des fonctionnalités <%= image_tag('warning.png', :title => "Alerte !",:alt =>"incident", :height =>"16px", :width =>"16px" )%></span>
</noscript>



<p>
	<span style="color: green;float:left;display:none" id="notice_message"></span>
</p>
<p>
	<span style="color: red;float:left;" id="error_message"></span>
</p>



<span id="info_bulle_machine" style="position: absolute;left:0px;top:0px;z-index:500"></span>

</p>
<div id="liste_salles">
	<%= render :partial => "salles/listSalle", :locals => { :salles => @salles} %>
</div>

<aside class="ico_machine">
<div id="liste_machine_sans_salle" >
	<h2>Machine(s) sans salle</h2>
	<% @machines = Machine.find_all_by_salle_id(0) %>
	<%= render :partial => "machines/listMachine", :locals => { :machines => @machines, :salle_id => 0} %>
</div>
</aside>

<%= drop_receiving_element("liste_machine_sans_salle",							# The id of the receiving element
		  :accept => "machine",                                         		# The CSS class of the dropped element
		  :with   => "'machine_id=' + (element.id.split('_').last())+'&salle_id=0'",# The query string parameters
		  :url    => {:action=>:changeMachineSansSalle, :controller => :machines}                      # The action to call
		)%>

<br />

<div id="divAjouterSalle" style="display:none;">
<% remote_form_for :salle, 
	:url => {:action => 'create', :controller => 'salles'}, 
	#:update => "liste_salles", 
	:before => "$('loading_create_salle').show();$('error_nom_salle').innerHTML = '';", 
	:complete => "$('divAjouterSalle').hide();$('divLienAfficherSalle').show();$('salle_nom_salle').value = '';$('error_nom_salle').value = '';$('loading_create_salle').hide()", 
	:html => { :id => "new_salle" }, 
	:condition=>"validateFormSalle()!=false" do |f| %>
  <%= f.label "Nom" %>
  <%= f.text_field :nom_salle %>
  <%= submit_tag "Enregistrer "%><span id="error_nom_salle" style="color:red"></span>
  <%= image_tag('loading.gif', :id => "loading_create_salle", :style => "display:none", :alt =>"chargement", :height =>"20px", :width =>"20px")%>
 <% end -%>
 <%= link_to_function 'Annuler', "$('divAjouterSalle').hide();$('divLienAfficherSalle').show()" %>
</div>

<% if authenticated? %>
	<div id="divLienAfficherSalle">
		<span class="add"><%= link_to_function 'Ajouter une salle', "$('divAjouterSalle').show();$('divLienAfficherSalle').hide()" %></span>
	</div>
<% end %>



<div id="trash" style="display:none">
	
	<%= image_tag('loading.gif', :id => "loading_delete_trash", :style => "display:none", :alt =>"chargement", :height =>"16px", :width =>"16px")%>
</div>

<%= periodically_call_remote :url => {:controller=>'machines',
                                      :action => 'getPingMachines'},
                                      :frequency => 60
		%>
<%= drop_receiving_element('trash',                             # The id of the receiving element
	  :accept => "machine",                                         # The CSS class of the dropped element
	  :with   => "'id=' + (element.id.split('_').last())",     # The query string parameters
	  :url    => {:controller => :machines, :action => :destroy},# The action to call
	  :before =>  "$('loading_delete_trash').show()",
	  :complete =>  "$('loading_delete_trash').hide()",
	  :confirm => 'Etes-vous sur de supprimer cette machine ?'
	)%>
	<%= drop_receiving_element('trash',                             # The id of the receiving element
	  :accept => "nom_salle",                                         # The CSS class of the dropped element
	  :with   => "'id=' + (element.id.split('_').last())",     # The query string parameters
	  :url    => {:controller => :salles, :action => :destroy},                          # The action to call
	  :before =>  "$('loading_delete_trash').show()",
	  :complete =>  "$('loading_delete_trash').hide()",
	  :confirm => 'Etes-vous sur de supprimer cette salle ?'
	)%>

